package com.guxingke.gblog.controller.intercepter;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;

import com.guxingke.gblog.service.UserService;
import com.guxingke.gblog.service.impl.UserServiceImpl;

public class ManageAuthIntercepter extends HandlerInterceptorAdapter {
	protected UserService userService = new UserServiceImpl();
	
	@Override
    public boolean preHandle(HttpServletRequest  request,HttpServletResponse  response,
            Object handler)
    		throws Exception{
		if (request.getSession().getAttribute("admin") != null) {			
				return true;
		}
		       
        response.setCharacterEncoding("utf-8");
        response.sendRedirect(request.getContextPath()+"/home.do");
        return false;
    }
}
